# setup.py
#
# Copyright (c) 2006 Michael Hobbs
#
# This file is part of iTorrent.
#
# iTorrent is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# iTorrent is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iTorrent; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


from distutils.core import setup
import os
import sys

import version
import utils

try:
	import py2exe
	osx = False
except:
	pass
# end try
try:
	import py2app
	osx = True
except:
	pass
# end try


# needed for py2exe to find win32com.shell; from http://starship.python.net/crew/theller/moin.cgi/WinShell
try:
	import modulefinder
	import win32com
	import win32com.shell
	for dirName in win32com.__path__[1:]:
		modulefinder.AddPackagePath('win32com', dirName)
	for dirName in win32com.shell.__path__[1:]:
		modulefinder.AddPackagePath('win32com.shell', dirName)
	# end for
except ImportError:
	# no build path setup, no worries.
	pass


setupVersion = version.VERSION
setupArgs = {}
if osx:
	setupArgs = dict(
			app=['iTorrent.py'],
			data_files=[('', ['iTorrent-helper/build/Release/iTorrent-helper'])],
			)
else:
	if len(sys.argv) > 1 and sys.argv[1] == 'py2exe':
		setupVersion = setupVersion.replace('alpha-', '0.0.')
	setupArgs = dict(
			console=['iTorrent.py'],
			options={"py2exe": {"compressed": True, "bundle_files": 1}},
			zipfile=None,
			)
# end if


setup(
		name='iTorrent',
		version=setupVersion,
		description='Download BitTorrent podcasts from iTunes',
		license='GNU General Public License',
		url='http://www.itorrent.cc',
		download_url='http://sourceforge.net/project/showfiles.php?group_id=163841&package_id=185388&release_id=415006',
		author='Michael Hobbs',
		author_email='mike@hobbshouse.org',
		long_description=\
				'iTorrent allows you to download BitTorrent podcasts from iTunes. It\n' \
				'transforms BitTorrent podcasts so that you can update them just like\n' \
				'any other podcast in iTunes. iTorrent also has the ability to smooth\n' \
				'out the downloads for non-BitTorrent podcasts as well, so that you do\n' \
				'not get frequent timeouts in iTunes when it updates multiple podcasts\n' \
				'at once.\n' \
				'\n' \
				'Technical Details: iTorrent runs as an RSS proxy on your local machine\n' \
				'and will fetch enclosures from a BitTorrent network on behalf of\n' \
				'iTunes. The BitTorrent content will then be fed to iTunes via a\n' \
				'standard HTTP connection.',
		keywords=['itunes', 'bittorrent', 'torrent', 'podcast', 'itorrent'],
		classifiers=[
				'Development Status :: 3 - Alpha',
				'Environment :: Console',
				'Environment :: MacOS X',
				'Environment :: Win32 (MS Windows)',
				'Intended Audience :: End Users/Desktop',
				'License :: OSI Approved :: GNU General Public License (GPL)',
				'Natural Language :: English',
				'Operating System :: MacOS :: MacOS X',
				'Operating System :: Microsoft :: Windows :: Windows NT/2000',
				'Programming Language :: Python',
				'Topic :: Multimedia :: Sound/Audio',
				'Topic :: Multimedia :: Video',
				'Topic :: Communications :: File Sharing',
				],

		packages = ['', 'BitTorrent', 'khashmir'],
		package_dir = {
				'BitTorrent': os.path.join(utils.getBTDir(), 'BitTorrent'),
				'khashmir': os.path.join(utils.getBTDir(), 'khashmir'),
				},
		**setupArgs)
